<template>
  <img :src="imgBase64" />
</template>

<script>
import jrQrcode from "jr-qrcode";

export default {
  name: "QrCode",
  props: {
    value: {
      type: String,
      require: true,
    },
    options: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      imgBase64: "",
    };
  },
  mounted() {
    this.imgBase64 = jrQrcode.getQrBase64(this.value, this.options);
  },
  watch: {
    value(newVal) {
      this.imgBase64 = jrQrcode.getQrBase64(newVal, this.options);
    },
    options(newVal) {
      this.imgBase64 = jrQrcode.getQrBase64(this.value, newVal);
    },
  },
};
</script>

<style></style>
